﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>test()方法应用示例</title>
</head>
<body>
    <script>
        let str = "Hello JavaScript!";
        //查找"Hello"
        let patt = /Hello/g;
        let result = patt.test(str);
        document.write("返回值: " + result);
        //查找 "W3Cschool"
        patt = /World/g;
        result = patt.test(str);
        document.write("<br>返回值: " + result);
    </script>
</body>
</html>